<template>
  <view class="container">
    <view class="box">
      <view class="cell flex">
        <view class="name">个人资料</view>
        <view class="icon"></view>
      </view>
      <view class="cell flex">
        <view class="name">账号安全</view>
        <view class="icon"></view>
      </view>
    </view>
    <view @click="logoutClick" class="btn">退出登录</view>
  </view>
</template>

<script setup>
import { logout } from '@/api/my.js';
import { useUserStore } from '@/store/userStore.js';

const userStore = useUserStore();
const logoutClick = async () => {
  const { code } = await logout();
  if (code == 0) {
    userStore.clearAll();
    userStore.$reset();
    uni.reLaunch({
      url: '/subPages/login/login',
    });
  }
};
</script>

<style lang="scss" scoped>
.container {
  min-height: 100vh;
  background-color: #f8f8f8;
  padding: 12px;
  .box {
    background-color: #fff;
    border-radius: 12px;
    padding: 0 12px;
    .cell {
      height: 52px;
      justify-content: space-between;
      &:not(:last-child) {
        border-bottom: 1px solid #f0f0f0;
      }
      .name {
        color: #333;
        font-weight: 400;
        font-size: 14px;
      }
      .icon {
        width: 8px;
        height: 8px;
        border-top: 2px solid #999;
        border-right: 2px solid #999;
        transform: rotate(45deg);
      }
    }
  }
  .btn {
    margin-top: 30px;
    text-align: center;
    line-height: 50px;
    color: #fff;
    background: linear-gradient(51.35deg, #ff0c1b 10.25%, #ff474f 80.97%);
    border-radius: 32px;
    font-weight: 500;
    font-size: 16px;
    line-height: 50px;
  }
}
</style>
